<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\helpers\SimpleFlagHelper;
use backend\helpers\ActionButton;
use backend\models\Event;
use yii\grid\GridView;
use backend\widgets\Chart\ChartWidget;
use backend\widgets\Chart\SalesTariffWidget;
use backend\widgets\Chart\SalesOnlineOfflineWidget;
use backend\widgets\Chart\SalesPaymentMethodWidget;
use backend\widgets\Chart\SalesPlatformWidget;
use backend\widgets\Chart\SalesPushkinCancellWidget;

/* @var $this yii\web\View */
/* @var $model backend\models\Event */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'События', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

$this->params['id'] = $model->id;

?>
<div class="container event-view">

    <h1 class="main-title"><?= Html::encode($this->title) ?></h1>

    <div class="row">
        <div class="col-sm-11"><?= $this->render('/event/_menu') ?></div>
        <div class="col-sm-1"><?= ActionButton::delete($model->id, 'Вы точно хотите удалить событие?', 'deleteEvent') ?></div>
    </div>

    <p>
        <?= ActionButton::custom('Загрузить таблицу онлайн-продаж', 'updateEvent', 'parse-online-sale', ['id_event'=>$model->id]) ?>
        <?= ActionButton::custom('Загрузить таблицу оффлайн-продаж', 'updateEvent', 'parse-offline-sale', ['id_event'=>$model->id]) ?>
    </p>


    <?= ChartWidget::widget(['event_id' => $model->id]); ?>

    <div class="row">
        <div class="col-sm-4">
            <?= SalesTariffWidget::widget(['event_id' => $model->id]); ?>
        </div>
        <div class="col-sm-4">
            <?= SalesOnlineOfflineWidget::widget(['event_id' => $model->id]); ?>
        </div>
        <div class="col-sm-4">
            <?= SalesPushkinCancellWidget::widget(['event_id' => $model->id]); ?>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-4">
            <?= SalesPlatformWidget::widget(['event_id' => $model->id]); ?>
        </div>
        <div class="col-sm-4">
            <?= SalesPaymentMethodWidget::widget(['event_id' => $model->id]); ?>
        </div>
        <div class="col-sm-4">
            
        </div>
    </div>
    
    <div class="row">
        
        <div class="col-sm-6">
        </div>
    </div>

    <?= GridView::widget([
        'dataProvider' => $salesDataProvider,
        'tableOptions' => [
            'class' => 'table table-striped'
        ],
        'pager' => [
            'firstPageLabel' => '|«',
            'lastPageLabel'  => '»|'
        ],
        'showFooter' => true,
        //'filterModel' => $searchModel,
        'columns' => [
        
            'id',
            'date_sale',
            'is_cancell',
            'is_refund',
            [
                'attribute' => 'tariff',
                'format' => 'currency',
                'footer'=> 'Итого: ' . Yii::$app->formatter->asCurrency($salesDataProvider->query->sum('tariff')),
            ],
            'selling_platform',
            'payment_method',

            [
                'class' => 'yii\grid\ActionColumn',
                'controller' => 'ticket-sales',
                'visibleButtons' =>
                [
                    'view' => Yii::$app->user->can('browseTicketSales'),
                    'update' => Yii::$app->user->can('updateTicketSales'),
                    'delete' => Yii::$app->user->can('deleteTicketSales'),
                ]
            ],
        ],
    ]); ?>

</div>
